Learn about the different control structures available in Visual Basic for controlling program flow
Learn about compiler directives
Introduce the looping constructs in Visual Basic
Sample Project File: \Chapter08\IfLoops.vbp
If . . . Then
An If...Then statement is used to redirect program flow based on the results of a conditional test. There are two forms of the If...Then statement: single line and multiline. You should only use the multiline statement because its much easier to read.
Heres the single-line syntax:
If <Cond> Then <Statement>
<Cond> can be any expression that evaluates to a True or False value. True is defined as any nonzero number, such as 1, 1, 2, 500, and so on. False, on the other hand, is zero (0).
Heres an example:
If txtLast.Text = "" Then MsgBox "Last Name Must be Filled In"
If . . . Then . . . End If
The multiline form of the If...Then statement is terminated with an End If statement. You need to use the End If statement if you have multiple lines of code in between the If and End If statements.
Examples Filename: Employee1.frm
Heres the multiline syntax:
If <Cond> Then
<Statement Block 1>
<Statement Block 2>
<Statement Block ...>
<Statement Block n>
End If